package se.teamstat.client.gui.admin.player;

import se.teamstat.client.gui.admin.matchserie.MatchSeriePanel;
import se.teamstat.client.gui.admin.team.TeamPanel;
import se.teamstat.client.service.ServiceFactory;
import se.teamstat.client.service.ServiceFactoryImpl;

import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;

public class EntityTabPanel extends Panel {
	
	private ServiceFactory serviceFactory;
	
	private EntityTabPanel() {
		serviceFactory = new ServiceFactoryImpl();
		init();
	}
	
	public static Panel createPanel() {
		Panel panel = new EntityTabPanel();
		return panel;
	}
	
	private void init() {
		setTitle("EntityTab");
		setBorder(false);
		
		final TabPanel tabPanel = new TabPanel();
		tabPanel.setActiveItemID("player-item");

		Panel playerPanel = PlayerPanel.createPanel();
		Panel teamPanel = TeamPanel.createPanel();
		Panel matchSeriePanel = MatchSeriePanel.createPanel();
		tabPanel.add(playerPanel);
		tabPanel.add(teamPanel);
		tabPanel.add(matchSeriePanel);
		
		add(tabPanel);
		
//		final AsyncCallback<List<EntityDTO>> callbackList = new AsyncCallback<List<EntityDTO>>() {
//			public void onSuccess(List<EntityDTO> entityList) {
//				MessageBox.alert("success:" + entityList);
//			}
//
//			public void onFailure(Throwable caught) {
//				MessageBox.alert("failed");
//			}
//		};

//		ButtonListenerAdapter listenerCancel = new ButtonListenerAdapter() {
//			public void onClick(Button button, EventObject e) {
//				EntityPanel activePanel = (EntityPanel) tabPanel.getActiveTab();
//				EntityDTO entity = activePanel.getEntity();
//				getService(entity.getClass()).getAll(callbackList);
//			}
//		};

		
		
		
		
		
	}
	
	
	
//	public Panel getWizard() {
//		final Panel wizardPanel = new Panel();  
//        wizardPanel.setHeight(250);  
//        wizardPanel.setWidth(350);  
//        wizardPanel.setTitle("Example Wizard");  
//        wizardPanel.setLayout(new CardLayout());  
//        wizardPanel.setActiveItem(0);  
//        wizardPanel.setPaddings(15);  
//  
//        ButtonListenerAdapter listener = new ButtonListenerAdapter() {  
//            public void onClick(Button button, EventObject e) {  
//                String btnID = button.getId();  
//                CardLayout cardLayout = (CardLayout) wizardPanel.getLayout();  
//                String panelID = cardLayout.getActiveItem().getId();  
//  
//                if (btnID.equals("move-prev")) {  
//                    if (panelID.equals("card-3")) {  
//                        cardLayout.setActiveItem(1);  
//                    } else {  
//                        cardLayout.setActiveItem(0);  
//                    }  
//                } else {  
//  
//                    if (panelID.equals("card-1")) {  
//                        cardLayout.setActiveItem(1);  
//                    } else {  
//                        cardLayout.setActiveItem(2);  
//                    }  
//                }  
//            }  
//        };  
//  
//        Toolbar toolbar = new Toolbar();  
//  
//        ToolbarButton backButton = new ToolbarButton("Back", listener);  
//        backButton.setId("move-prev");  
//        toolbar.addButton(backButton);  
//        toolbar.addFill();  
//  
//        ToolbarButton nextButton = new ToolbarButton("Next", listener);  
//        nextButton.setId("move-next");  
//        toolbar.addButton(nextButton);  
//  
//        wizardPanel.setBottomToolbar(toolbar);  
//  
//        Panel first = new Panel();  
//        first.setBorder(false);  
//        first.setId("card-1");  
//        first.setHtml("<h1>Welcome to the Wizard!</h1><p>Step 1 of 3</p>");  
//  
//        Panel second = new Panel();  
//        second.setBorder(false);  
//        second.setId("card-2");  
//        second.setHtml("<p>Step 2 of 3</p>");  
//  
//        Panel third = new Panel();  
//        third.setBorder(false);  
//        third.setId("card-3");  
//        third.setHtml("<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>");  
//  
//        wizardPanel.add(first);  
//        wizardPanel.add(second);  
//        wizardPanel.add(third);  
//  
//        return wizardPanel;
//	}
}
